﻿package II.controls {
	
	import flash.display.*;
	
	public class UIBase extends Sprite {

		// fix left, fix right, full
		
		
		public function UIBase() {
			// constructor code
			
		}

		
/*		public function get binding () : String {
			return _binding;
		}
		public function set binding ( value:String ) : void {
			_binding = value;
		}
		private var _binding:String = null;
		
		protected function Costructor (): void {
		}		
		protected function Destructor (): void {
		}
*/
		
		// DATACONTEXT
		
		public function get dataContext () : Object {
			return _dataContext;
		}
		public function set dataContext ( value:Object ) : void {
			_dataContext = value;
			
			for ( var cont:int = 0; cont<this.numChildren; cont++ ) {
				var child:UIBase = this.getChildAt(cont) as UIBase;
				if ( child!=null ) child.dataContext = this.dataContext;
			}
		}
		var _dataContext:Object = null;

		// DATACONTEXT
		
		
		
		public function set size ( size:Size ) : void {
			_size = size;
			//this.updateLayout();
		}
		public function get size () : Size {
			return _size;
		}
		protected var _size:Size = null;
		
		public function updateLayout() : void {
			this.size = new Size ( this.width, this.height );
			this.updateLayoutAllChild();
		}
		protected function updateLayoutAllChild() : void {
			for ( var cont:int = 0; cont<this.numChildren; cont++ ) {
				var child:UIBase = this.getChildAt(cont) as UIBase;
				if ( child != null ) child.updateLayout();
			}
		}
		
	}
	
}
